package com.daiyang.ioc.controller;


import com.daiyang.ioc.configuration.BeanConfig;
import com.daiyang.ioc.medol.User;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController2 {
//   @Autowired
//   @Qualifier(value="u1")
//    @Resource(name="u2")
   private User user1;
   private User user2;
   private User user3;
//  @Resource(name = "u2")
//   private User user2;


    public UserController2() {

    }

    @Autowired
    public UserController2(  @Qualifier("u1") User user1 ) {
        this.user1 = user1;
    }

    UserController2(@Qualifier("u2") User user2, @Qualifier("u2") User user3) {
        this.user2 = user2;
        this.user3 = user3;
    }
//   @Resource(name ="u1")
//    public void setUser(@Qualifier("u2") User user) {
//        this.user = user;
//    }

    public void say() {
        System.out.println("UserController2.say");
        //  System.out.println(user)
        System.out.println("User1");
        System.out.println(user1);
        System.out.println("User2");
        System.out.println(user2);
        System.out.println("User3");
        System.out.println(user3);
    }
}
